home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / graphics.17 / graphics / graphics-0.17 / plot2tek / fill.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-03-21  |  1.0 KB  |  42 lines

  1. /* This file is the fill routine, which is an extension to the plot library.
  2.    It changes the grey level of the fill patter for all closed of the following
  3.    drawing operations. */
  4.  
  5. #include "sys-defines.h"
  6. #include "libplot.h"
  7.  
  8. /* FILL_LEVEL is the intensity of the filler for closed paths.  Intensity
  9.    ranges from 0 to 1. A value of 0 represents black and a value of 1 indicates
  10.    white. A value of -1 represents no fill at all (transparent). */
  11.  
  12. double fill_level = -1.;
  13.  
  14. /* FILL sets the intensity of the filler for closed paths.  LEVEL ranges
  15.    from 1 to 0xFFFF. A value of 1 represents black and a value of 0xFFFF
  16.    indicates white. A value of 0 represents no fill - transparent. */
  17.  
  18. int
  19. fill (level)
  20.      int level;
  21. {
  22.   if (level == 0)
  23.     {
  24.       fill_level = -1.;
  25.     }
  26.   else
  27.     {
  28.       fill_level = ((double)level - 1.)/0xFFFE;
  29.       /* The value of fill level should be between 0 and 1,
  30.      which is enforced here. */
  31.       if (fill_level > 1.)
  32.     {
  33.       fill_level = 1.;
  34.     }
  35.       else if (fill_level < 0.)
  36.     {
  37.       fill_level = 0.;
  38.     }
  39.     }
  40.   return 0;
  41. }
  42.